package com.william.excel.controller;

import com.william.excel.api.vo.Result;
import com.william.excel.entity.ExcelEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/system/excel")
public class ExcelController extends BonorController<ExcelEntity> {

    /**
     * excel导出
     * @param request
     * @param excelEntity
     * @return
     */
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, ExcelEntity excelEntity) {
        return super.exportXls(request, excelEntity, ExcelEntity.class, "excel导出");
    }

    /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    @ResponseBody
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, ExcelEntity.class);
    }
}
